<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>规则库列表</title>
<link href="../../static/plugin/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../../static/plugin/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/plugin/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/plugin/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/plugin/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/plugin/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">
    var ruleCollId;
	$(function() {
        ruleCollId = $.getUrlParam('ruleCollId');
        $('#dg').datagrid({url: '../../api/s/rule/infos/coll', queryParams : { 'ruleCollId': ruleCollId}})
    });

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};

    function query() {
        var param = $("#searchForm").serializeJson();
        param.ruleCollId = ruleCollId;
        param.ruleTyp = param.ruleType;
        delete param.ruleType;
        $('#dg').datagrid('load', param);
    }

    function submitChoose() {
		var rows = $('#dg').datagrid('getSelections');
		if (rows && rows.length > 0) {
		    for (var i =0; i < rows.length; i++) {
		        rows[i].ruleCollId = ruleCollId;
		        rows[i].ruleCfgDesc = rows[i].ruleDesc;
		        rows[i].ruleTyp = rows[i].ruleType;
			}
            $.restfulPostJson("../../api/s/rule/coll/detail/add", rows, function(data){
                window.parent.JLEUtil.triggerParent('#detailDg', "SRuleInfoListChooseEvent", [data]);
                cancel();
			}, function(data) {
                $.messager.alert('提示',data.message,'error');
			});

        } else {
            $.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function cancel() {
        window.parent.JLEUtil.closewin();
	}
</script>
<body class="easyui-layout">
<div data-options="region:'north',title:'',minHeight: 100">
	<form id="searchForm" class="control-form center-block ">
		<div class="row">
			<div class="form-group col-md-4 row">
				<label for="ruleId" class="col-md-4 control-label">规则id：</label>
				<div class="col-md-8">
					<input type="text" class="form-control input-sm" name="ruleId" id="ruleId">
				</div>
			</div>
			<div class="form-group col-md-4 row">
				<label for="ruleType" class="col-md-4 control-label">规则类型：</label>
				<div class="col-md-8">
					<select class="easyui-combobox"
							id="ruleType" name="ruleType"
							style="width: 100%; height: 25px;"
							data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:RULE_TYPE">
					</select>
				</div>
			</div>
			<div class="form-group col-md-4 row">
				<label for="ruleName" class="col-md-4 control-label">规则名称：</label>
				<div class="col-md-8">
					<input type="text" class="form-control input-sm" name="ruleName" id="ruleName">
				</div>
			</div>
		</div>
		<div class="row">
			<div class="form-group col-md-12 text-center">
				<a class="easyui-linkbutton" href="javascript:void(0);" onclick="query()">查找</a>
				<a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a>
			</div>
		</div>
	</form>
</div>
<div data-options="region:'center',split:false">
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:100%"
			data-options="checkbox:true,selectOnCheck:true,collapsible:true,method:'post'"
			toolbar="#tb"
		title="Load Data"
	    rownumbers="true" pagination="true" pageSize="5" pagePosition="top" pageList="[5,10]">
		<thead>
			<tr>
				<th data-options="field:'checked',checkbox:true,resizable:true" >选择</th>
				<th data-options="field:'ruleId',resizable:true" sortable="true">规则id</th>
				<th data-options="field:'ruleName',resizable:true" >规则名称</th>
				<th data-options="field:'ruleDesc',resizable:true" >规则描述</th>
				<th data-options="field:'ruleType',resizable:true" formatter="formatter_RULE_TYPE">规则类型</th>
				<th data-options="field:'adapterType',resizable:true" formatter="formatter_ADAPTER_TYPE">规则适用类型</th>
				<th data-options="field:'createUser',resizable:true" >创建用户</th>
				<th data-options="field:'createTime',resizable:true" >创建日期</th>
				<th data-options="field:'updateTime',resizable:true" >最后修改时间</th>
				<th data-options="field:'updateUser',resizable:true" >最新变更用户</th>
			</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:submitChoose()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">确认选择</a>
		<a href="javascript:cancel()" class="easyui-linkbutton" iconCls="icon-cancel" plain="true">取消</a>
	</div>
</div>
<!--<div id="opDiv" style="padding:1px">
	<div style="text-align: center; padding: 15px">
		<a href="javascript:void(0)" class="easyui-linkbutton"
		   onclick="submitChoose()">确认选择</a>
		<a href="javascript:void(0)" class="easyui-linkbutton"
			onclick="cancel()">&nbsp;取&nbsp;消&nbsp;</a>
	</div>
</div>-->
</body>
</html>
